-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
colexec: add support for bit and some arithmetic binary operators #49761
Conversation
These are the third and fourth commit that were extracted from #49419. |
I gave this an LGTM in the other PR so leaving to @jordanlewis to review. |
1a76721
to
18e91f5
Compare
@jordanlewis I'm assuming you want to take a look at this when you get a chance (it's not urgent), right? |
Sorry, I've been behind in the reviews last couple of days. |
No worries, I understand, just checking that I should wait before merging this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 7 of 7 files at r1.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @asubiotto, @jordanlewis, and @yuzefovich)
pkg/sql/colexec/execgen/cmd/execgen/overloads_bin.go, line 257 at r1 (raw file):
{{if .CheckRightIsZero}} if {{.Right}} == 0.0 { colexecerror.ExpectedError(tree.ErrDivByZero)
LGTM. As a (non-blocking) idea, would it make sense to introduce a new operator in the chain before division operators, that returns the error if any divisor is 0? I'm not positive, but based on lessons we've learned from vectorized, it seems at least likely that it would be more efficient to do the check in a single pass.
Release note (bug fix): Previously, in some cases, CockroachDB didn't check whether the right argument of `Div` (`/`), `FloorDiv` (`//`), or `Mod` (`%`) operations was zero, so instead of correctly returning a "division by zero" error, we were returning `NaN`, and this is now fixed. Additionally, the error message of "modulus by zero" has been changed to "division by zero" to be inline with Postgres.
18e91f5
to
53259ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTRs!
bors r+
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @asubiotto and @jordanlewis)
pkg/sql/colexec/execgen/cmd/execgen/overloads_bin.go, line 257 at r1 (raw file):
Previously, jordanlewis (Jordan Lewis) wrote…
LGTM. As a (non-blocking) idea, would it make sense to introduce a new operator in the chain before division operators, that returns the error if any divisor is 0? I'm not positive, but based on lessons we've learned from vectorized, it seems at least likely that it would be more efficient to do the check in a single pass.
Oh, that's an interesting idea. I agree that it is likely to be more performant, left a TODO for this.
bors r- A minor typo in the comment. |
Canceled |
This commit adds support for `Bitand`, `Bitor`, `Bitxor`, `FloorDiv`, and `Mod` binary operators for both native and datum-backed types. Release note (sql change): Vectorized execution engine now supports `Bitand` (`&`), `Bitor` (`|`), `Bitxor` (`^`), `FloorDiv` (`//`), and `Mod` (`%`) binary operators.
53259ad
to
ca6c664
Compare
bors r+ |
Build succeeded |
Hello there! I would like to ask one I wasn't able to answer on my own. Thanks! |
You're welcome @tancredosouza , thanks for looking into this!
I think what might be confusing is that we have two kinds of representations for different types. For some types (like But for others (like Furthermore, for optimized types we do the translation of the relevant code in |
It does! Thanks. |
sem: unify division by zero check and fix it in a few places
Release note (bug fix): Previously, in some cases, CockroachDB didn't
check whether the right argument of
Div
(/
),FloorDiv
(//
),or
Mod
(%
) operations was zero, so instead of correctly returninga "division by zero" error, we were returning
NaN
, and this is nowfixed. Additionally, the error message of "modulus by zero" has been
changed to "division by zero" to be inline with Postgres.
colexec: add support for bit and some arithmetic binary operators
This commit adds support for
Bitand
,Bitor
,Bitxor
,FloorDiv
,and
Mod
binary operators for both native and datum-backed types.Release note (sql change): Vectorized execution engine now supports
Bitand
(&
),Bitor
(|
),Bitxor
(^
),FloorDiv
(//
), andMod
(%
) binary operators.